package com.hns.phone.maintenance.web;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hns.can.common.service.CommonInitParamService;
import com.hns.can.common.vo.CommonParamsVo;
import com.hns.can.common.web.BaseController;
import com.hns.can.master.entity.CommCarCurrentLoInfoEntity;
import com.hns.phone.common.vo.CommDriveTrajInfoVo;
import com.hns.phone.entity.CommDriveTrajInfoEntity;
import com.hns.phone.maintenance.service.PhoneDriveRecordService;

/**
 * @版权：HNS 版权所有 (c) 2013
 * @author:zhangy
 * @version Revision 1.0.0
 * @email:zhangyu2222z@sina.cn
 * @see:
 * @创建日期：2015年4月2日
 * @功能说明：行驶历史记录
 * @begin
 * @修改记录:
 * @修改后版本          修改人      	修改内容
 * @2015年4月2日  	       zhangy       	创建
 * @end
 */
@Controller
@RequestMapping("/api/phoneDriveRecord")
public class PhoneDriveRecordController extends BaseController {
	
	@Autowired
	private PhoneDriveRecordService phoneDriveRecordService;
	
	@Autowired
    private CommonInitParamService commonInitParamService;
	
	/**
	 * @param entity
	 * @param request
	 * @param response
	 * @throws Exception
	 * @author:zhangy
	 * @email:zhangyu2222z@sina.cn
	 * @创建日期:2015年4月2日
	 * @功能说明：查询车辆行驶轨迹
	 */
	@RequestMapping("/getDriveTrajInfo")
	@ResponseBody
	public Object getDriveTrajInfoForMobile(CommonParamsVo entity,
			HttpServletRequest request,HttpServletResponse response) throws Exception {
		entity.setCarIds(new String[]{entity.getCarId()});
		commonInitParamService.initParamsLimitCar(entity, this.getPhoneCurrentUser(), null);
		List<CommDriveTrajInfoVo> results = phoneDriveRecordService.getDriveTrajInfoForMobile(entity);
		return this.getReturnResult(results);
	}
	
	/**
	 * @param entity
	 * @param request
	 * @param commonInitParamService
	 * @return
	 * @throws QueryExprException
	 * @author:zhangy
	 * @email:zhangyu2222z@sina.cn
	 * @创建日期:2015年4月16日
	 * @功能说明：获取指定车辆末次位置
	 */
	@RequestMapping("/getLastTrajInfo")
	@ResponseBody
	public Object getLastTrajInfoForMobile(CommonParamsVo entity,
			HttpServletRequest request,HttpServletResponse response) throws Exception {
		commonInitParamService.setOrgIds(entity, null, this.getPhoneCurrentUser(), null);
		List<CommCarCurrentLoInfoEntity> results = phoneDriveRecordService.getLastTrajInfoForMobile(entity, request, commonInitParamService);
		return this.getReturnResult(results);
	}
}
